<template>
	<el-dialog title="数据字典修改" :visible.sync="visible" width="500px" :center="false" >
		<div slot="title" class="dialog-header-title">
			<i class="el-icon-edit" style="color: #FFF"></i>&nbsp;
			<span style="color: #FFF">数据字典修改</span>
		</div>

		<div class="smp-search">
			<el-form :inline="false" label-width="100px" size="mini" ref="form" :model="form" :rules="rules">
				<el-row>
					<el-col :span="24">
						<el-form-item label="字典项编码:" prop="itemCode">
							<el-input v-model="form.itemCode":disabled="true" placeholder="请输入字典项编码"></el-input>
						</el-form-item>
					</el-col>
					<el-col :span="24">
					<el-form-item label="字典编码:" prop="dictCode" >
						<el-select v-model="form.dictCode" :disabled="true"style="width: 100%"
							placeholder="字典编码" >
							<el-option v-for="item in dict('SMP0001')" :key="item.itemCode" :label="item.itemName"
								:value="item.itemCode">
							</el-option>
						</el-select>
					</el-form-item>
					</el-col>
					<el-col :span="24">
						<el-form-item label="字典项名称:" prop="itemName ">
							<el-input v-model="form.itemName" placeholder="请输入字典项名称"></el-input>
						</el-form-item>
					</el-col>
					
					<el-col :span="24">
					<el-form-item label="状态:" prop="status" >
						<el-select v-model="form.status" style="width: 100%"
							placeholder="状态" >
							<el-option v-for="item in dict('SMP0005')" :key="item.itemCode" :label="item.itemName"
								:value="item.itemCode">
							</el-option>
						</el-select>
					</el-form-item>
					</el-col>
					
					
					<!-- <el-col :span="24">
						<el-form-item label="菜单级别:" prop="level" >
							<el-input v-model="form.level":disabled="true" placeholder="请输入菜单级别"> </el-input>
						</el-form-item> 
					</el-col> -->

				</el-row>
			</el-form>
		</div>
		<span slot="footer" class="dialog-footer">
			<el-button type="primary" plain @click="submit" size="mini">
					<i class="el-icon-check"></i>
					确定</el-button>
				<el-button @click="visible = false" size="mini">
					<i class="el-icon-close"></i>
					取消</el-button>
				
			</span>
		</span>
	</el-dialog>
</template>
<script>
"use strict";
import {updatedataDictionary} from '@/api/dataDictionary.js';
	export default {
		data() {
			return {
				visible: false,
				form: {
					itemCode: "",
					itemName: "",
					status: "",
					dictCode: "",
				},
				rules: {
					itemCode: [{
						required: true,
						message: '请输入字典编码项',
						trigger: 'blur'
					}],
					itemName: [{
						required: true,
						message: '请输入字典项名称',
						trigger: 'blur'
					}],
					dictCode: [{
						required: true,
						message: '请选择字典编码',
						trigger: 'blur'
					}],
					status: [{
						required: true,
						message: '请选择状态',
						trigger: 'blur'
					}],
				}
			}

		},
		methods: {
			ShowDialog(row) {
			   Object.assign(this.form,row);
				this.visible = true;
			},
			handleCancel(e) {
				this.visible = false;
			},
			submit() {//新增
			this.$refs["form"].validate((valid)=>{
				if(valid){
					updatedataDictionary(this.form).then(response => {
						if(response.data.code == "0000"){
							this.$message.success(response.data.message);
						}else{
							this.$message.error(response.data.message);
						}
						
						
					}).catch(error => {
						this.$message.error(error.message);
					});
					this.visible = false;
					this.$emit("fresh")
				}
			});
			
		
				
			},
		}
	};
</script>
